package cc.lj.internal.merchant.application.service;

import cc.lj.internal.merchant.domain.contract.model.vo.MerchantContractSignedDO;
import cc.lj.internal.merchant.domain.contract.service.IMerchantContractSignedDomainService;
import cc.lj.internal.merchant.interfaces.dto.MerchantContractSignedDTO;
import cc.lj.internal.merchant.interfaces.dto.convert.MerchantContractSignedDTOConvertDO;
import cc.lj.internal.merchant.interfaces.dto.query.MerchantContractSignedQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 商户合同签订表 app service
 * @author liangxifeng
 * @date 2022-07-09
 */
@Slf4j
@Service(value = "merchantContractSignedAppService")
public class MerchantContractSignedAppService {

    @Resource(name = "merchantContractSignedDomainServiceImpl")
    private IMerchantContractSignedDomainService domainService;

    /**
     * 通过展位号和商户K代码查询
     * @param signedQuery
     * @return
     */
    public List<MerchantContractSignedDTO> getList(MerchantContractSignedQuery signedQuery) {
        MerchantContractSignedDO signedDO = new MerchantContractSignedDO();
        signedDO.setConResource(signedQuery.getConResource()); //展位号
        signedDO.setConMerchantId(signedQuery.getConMerchantId()); //代码
        return domainService.getList(signedDO).stream().map(x -> MerchantContractSignedDTOConvertDO.INSTANCE.convert(x) ).collect(Collectors.toList());

    }
}
